package red.mlz.appconsumer.feign.user;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import red.mlz.common.entity.user.User;

import java.math.BigInteger;
import java.util.List;

@FeignClient(name = "user-service")
public interface UserFeign {

    @RequestMapping("/user-service/getByIds")
    List<User> getByIds(@RequestParam(name = "id")List<BigInteger> ids);

    @RequestMapping("/user-service/loginB")
    Boolean loginB(@RequestParam(name = "phone") String phone,
                  @RequestParam(name = "password") String password,
                  @RequestParam(name = "remember" , required = false) Boolean remember);

    //根据手机号查询用户
    @RequestMapping("/user-service/getByPhone")
    User getByPhone(@RequestParam String phone);

    //注册用户
    @RequestMapping("/user-service/register")
    BigInteger registerUser(@RequestParam(name = "name") String name,
                                             @RequestParam(name = "phone") String phone,
                                             @RequestParam(name = "gender") Integer gender,
                                             @RequestParam(name = "avatar", required = false) String avatar,
                                             @RequestParam(name = "password") String password,
                                             @RequestParam(name = "country", required = false) String country,
                                             @RequestParam(name = "province", required = false) String province,
                                             @RequestParam(name = "city", required = false) String city,
                                             @RequestParam(name = "ip") String ip);

    //刷新用户登录上下文
    @RequestMapping("/user-service/refresh")
    void refreshUserLoginContext(@RequestParam(name = "id") BigInteger id,
                                 @RequestParam(name = "ip") String ip,
                                 @RequestParam(name = "time") int time);

    @RequestMapping("/user-service/extractByPhone")
    User extractByPhone(@RequestParam(name = "phone") String phone,
                               @RequestParam(name = "countryCode") String countryCode);

    @RequestMapping("/user-service/getById")
    User getById(@RequestParam(name = "id") BigInteger id);

    @RequestMapping("/user-service/isGender")
    boolean isGender(@RequestParam(name = "gender") int gender);
}
